// 用户相关类型
export interface User {
  id: number
  username: string
  email: string
  full_name?: string | null
  bio?: string | null
  avatar_url?: string | null
  is_active: boolean
  is_admin: boolean
  created_at: string
  updated_at?: string | null
}

export interface UserCreate {
  username: string
  email: string
  password: string
  full_name?: string
  bio?: string
  avatar_url?: string
  invite_code: string
}

export interface UserLogin {
  username: string
  password: string
}

export interface UserUpdate {
  username?: string
  email?: string
  full_name?: string
  bio?: string
  avatar_url?: string
  password?: string
}

// 文章相关类型
export interface Post {
  id: string
  title: string
  content: string
  excerpt?: string | null
  cover_image?: string | null
  is_published: boolean
  is_featured: boolean
  view_count: number
  like_count: number
  created_at: string
  updated_at?: string | null
  published_at?: string | null
  author?: User | null
  category?: Category | null
  tags: Tag[]
}

export interface PostCreate {
  title: string
  content: string
  excerpt?: string
  cover_image?: string
  is_published: boolean
  is_featured: boolean
  category_id?: number
  tag_ids?: number[]
}

export interface PostUpdate {
  title?: string
  content?: string
  excerpt?: string
  cover_image?: string
  is_published?: boolean
  is_featured?: boolean
  category_id?: number
  tag_ids?: number[]
}

// 分类相关类型
export interface Category {
  id: number
  name: string
  description?: string
  color?: string
  created_at: string
  updated_at?: string
}

export interface CategoryCreate {
  name: string
  description?: string
  color?: string
}

// 标签相关类型
export interface Tag {
  id: number
  name: string
  description?: string
  color?: string
  created_at: string
  updated_at?: string
}

export interface TagCreate {
  name: string
  description?: string
  color?: string
}

// 评论相关类型
export interface Comment {
  id: number
  content: string
  is_approved: boolean
  created_at: string
  updated_at?: string
  author?: User | null
  post_id: string
  parent_id?: number
  replies?: Comment[]
}

export interface CommentCreate {
  content: string
  post_id: string
  parent_id?: number
}

// API响应类型
export interface ApiResponse<T = any> {
  data?: T
  message?: string
  status: number
}

export interface PaginatedResponse<T> {
  items: T[]
  total: number
  page: number
  size: number
  pages: number
}

// 认证相关类型
export interface Token {
  access_token: string
  token_type: string
}

export interface AuthState {
  user: User | null
  token: string | null
  isLoggedIn: boolean
}
